#! /bin/bash
echo "pull code..."
cd /root/code/matecloud-v1/
git pull
echo "maven clean install..."
mvn clean install -Dmaven.javadoc.skip=true -Dgpg.skip

######杀死进程echo "kill process..."


kill -9 `ps -ef | grep -w "mate-gateway.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-uaa.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-system.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-component.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-code.jar" | grep -v "grep" | awk '{print $2}'`



######关闭项目
sh /usr/local/deploy/matecloud-v1/mate-gateway.sh stop
echo "stop mate-gateway"
sh /usr/local/deploy/matecloud-v1/mate-uaa.sh stop
echo "stop mate-uaa"
sh /usr/local/deploy/matecloud-v1/mate-system.sh stop
echo "stop mate-system"
sh /usr/local/deploy/matecloud-v1/mate-component.sh stop
echo "stop mate-component"
sh /usr/local/deploy/matecloud-v1/mate-code.sh stop
echo "stop mate-code"

mkdir -p /usr/local/deploy/matecloud-v1/jar/


######copy文件/备份原文件

echo "copy files..."
rm -rf /usr/local/deploy/matecloud-v1/jar/mate-gateway.jar
rm -rf /usr/local/deploy/matecloud-v1/jar/mate-uaa.jar
rm -rf /usr/local/deploy/matecloud-v1/jar/mate-system.jar
rm -rf /usr/local/deploy/matecloud-v1/jar/mate-component.jar
rm -rf /usr/local/deploy/matecloud-v1/jar/mate-code.jar


cp -f /root/code/matecloud-v1/target/mate-gateway.jar  /usr/local/deploy/matecloud-v1/jar/mate-gateway.jar
cp -f /root/code/matecloud-v1/target/mate-uaa.jar  /usr/local/deploy/matecloud-v1/jar/mate-uaa.jar
cp -f /root/code/matecloud-v1/target/mate-system.jar  /usr/local/deploy/matecloud-v1/jar/mate-system.jar
cp -f /root/code/matecloud-v1/target/mate-component.jar  /usr/local/deploy/matecloud-v1/jar/mate-component.jar
cp -f /root/code/matecloud-v1/target/mate-code.jar  /usr/local/deploy/matecloud-v1/jar/mate-code.jar


######日志
echo "init log files"
mkdir -p  /usr/local/deploy/matecloud-v1/logs

# rm -rf /usr/local/deploy/matecloud-v1/logs/*.out*


######启动脚本
sh /usr/local/deploy/matecloud-v1/mate-gateway.sh start
sh /usr/local/deploy/matecloud-v1/mate-uaa.sh start
sh /usr/local/deploy/matecloud-v1/mate-system.sh start
sh /usr/local/deploy/matecloud-v1/mate-component.sh start
sh /usr/local/deploy/matecloud-v1/mate-code.sh start


echo "start matecloud"



